package com.item.controller;


import com.item.domain.CommentPay;
import com.item.service.CommentPayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class CommentPayController {

    @Autowired
    CommentPayService commentPayService;

    @PostMapping(value = "/commentPay/{limit}/{page}")
    public List<CommentPay> commentPay(
            @PathVariable(value = "limit", required = false) int limit,
            @PathVariable(value = "page", required = false) int page,
            @RequestBody(required = false) CommentPay commentPay) {
        List<CommentPay> commentPays = commentPayService.findAll(limit, page, commentPay);
        return commentPays;
    }

    @PostMapping(value = "/commentPay/add")
    public Integer commentPayAdd(@RequestBody CommentPay commentPay) {

        int i = commentPayService.add(commentPay);
        return i;
    }

    @PutMapping(value = "/commentPay/update")
    public Integer commentPayUpdate(@RequestBody CommentPay commentPay) {

        int i = commentPayService.update(commentPay);
        return i;
    }

    @DeleteMapping(value = "/commentPay/{id}")
    public Integer commentPayDelete(@PathVariable(value = "id") int id) {

        int i = commentPayService.delete(id);
        return i;
    }

}
